<?php

class Api{
    function post($req){
        $dataSource = pt\db\Mysql::init()->rows("select u.*,u.id as `key`,r.name as role_name from user as u left join role as r on r.id = u.role_id where u.creator = false order by u.id DESC ");
        $total = pt\db\Mysql::init()->row("select count(id) as num from user where creator = false  ");
        $columns = array(
            array(
                "title"=>"ID",
                "key"=>"id",
                "dataIndex"=>"id",
            ),
            array(
                "title"=>"姓名",
                "key"=>"name",
                "dataIndex"=>"name",
            ),
            array(
                "title"=>"手机",
                "key"=>"mobile",
                "dataIndex"=>"mobile",
            ),
            array(
                "title"=>"角色",
                "key"=>"role_name",
                "dataIndex"=>"role_name",
            ),
            array(
                "title"=>"操作",
                "key"=>"",
                "dataIndex"=>"",
            )
        );
        $res = array(
            "dataSource"=>$dataSource,
            "columns"=>$columns,
            "pagination"=>array(
                "total"=>$total['num'],
                "pageSize"=>5,
                "current"=>1,
            ),
        );
        return $res;
    }
}
